<?php
namespace Common\Controller;

use Common\Controller\AppframeController;

class AppmemberbaseController extends AppbaseController {
	protected $user;
	protected $userId;
	public function _initialize() {
		parent::_initialize();
        if(!IS_POST){
            $this->jsonReturn(0,'请求方式错误');
        }
        $token=I('token');
        if(!$token){
            $this->jsonReturn(2,'请先登陆');
        }
        $this->user=lt_get_user_by_token($token);
        if(!$this->user){
            $this->jsonReturn(2,'请先登陆');
        }
        if($this->user['status']==2){
            $this->jsonReturn(3,'请先绑定手机号');
        }
        if($this->user['status']!=1){
            $this->jsonReturn(0,'用户已被拉黑');
        }
        $this->userId=$this->user['id'];
	}

    protected function uploadFile($savepath){
        $config=array(
            'rootPath' => './'.C("UPLOADPATH"),
            'savePath' => $savepath.'/'.date('Ymd').'/',
            'maxSize' => 5242880,//5m
            'saveName'   =>    array('uniqid',''),
            'exts'       =>    ['jpg','png','jpeg','gif','bmp'],
            'autoSub'    =>    false,
        );
        $upload = new \Think\Upload($config);
        $info=$upload->upload();
        if($info){
            return ['status'=>'success','info'=>$info];
        }else{
            return ['status'=>'error','message'=>$upload->getError()];
        }
    }
}